package com.baorant.streamsender.controller;

import com.baorant.streamsender.service.ISenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private ISenderService sendService;

    @RequestMapping("/send")
    public String send() {
        String msg = "hello stream ...";
        Message message = MessageBuilder.withPayload(msg.getBytes()).build();
        sendService.send().send(message);
        return "ok";
    }
}